# Maintainers: James Spencer <james.s.spencer@gmail.com>
#              Darjan Krijan [https://disc-kuraudo.eu]

_realname=cubelib
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=4.8.2
pkgrel=1
pkgdesc="Library for reading and writing a multi-dimensional performance space (mingw-w64)"
arch=('any')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="http://www.scalasca.org/software/cube-4.x/download.html"
license=('BSD')
depends=("${MINGW_PACKAGE_PREFIX}-gcc-libs"
         "${MINGW_PACKAGE_PREFIX}-zlib"
         "${MINGW_PACKAGE_PREFIX}-qt5-base")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
             "${MINGW_PACKAGE_PREFIX}-fc")
source=("https://apps.fz-juelich.de/scalasca/releases/cube/${pkgver:0:3}/dist/${_realname}-${pkgver}.tar.gz")
sha256sums=('d6fdef57b1bc9594f1450ba46cf08f431dd0d4ae595c47e2f3454e17e4ae74f4')

build() {
  mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"

  local -a extra_args
  if [[ ${MINGW_PACKAGE_PREFIX} == *-clang-* ]]; then
    extra_args+=--with-nocross-compiler-suite=clang
  fi

  ../${_realname}-${pkgver}/configure CPPFLAGS="-I${MINGW_PREFIX}/include/QtCore -D_XOPEN_SOURCE=600" \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    "${extra_args[@]}" \

  make
}

package() {
  cd "${srcdir}/build-${MSYSTEM}"
  make install DESTDIR="${pkgdir}"
  install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/LICENSE
}
